<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<title>MiXiM: MiximBatteryAccess Class Reference</title>

<link href="tabs.css" rel="stylesheet" type="text/css"/>
<link href="doxygen.css" rel="stylesheet" type="text/css" />
<link href="navtree.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="resize.js"></script>
<script type="text/javascript" src="navtree.js"></script>
<script type="text/javascript">
  $(document).ready(initResizable);
</script>


</head>
<body>
<div id="top"><!-- do not remove this div! -->


<div id="titlearea">
<table cellspacing="0" cellpadding="0">
 <tbody>
 <tr style="height: 56px;">
  
  
  <td style="padding-left: 0.5em;">
   <div id="projectname">MiXiM
   &#160;<span id="projectnumber">2.3</span>
   </div>
   
  </td>
  
  
  
 </tr>
 </tbody>
</table>
</div>

<!-- Generated by Doxygen 1.7.5.1 -->
  <div id="navrow1" class="tabs">
    <ul class="tablist">
      <li><a href="index.html"><span>Main&#160;Page</span></a></li>
      <li><a href="pages.html"><span>Related&#160;Pages</span></a></li>
      <li><a href="modules.html"><span>Modules</span></a></li>
      <li class="current"><a href="annotated.html"><span>Classes</span></a></li>
      <li><a href="files.html"><span>Files</span></a></li>
      <li><a href="dirs.html"><span>Directories</span></a></li>
    </ul>
  </div>
  <div id="navrow2" class="tabs2">
    <ul class="tablist">
      <li><a href="annotated.html"><span>Class&#160;List</span></a></li>
      <li><a href="classes.html"><span>Class&#160;Index</span></a></li>
      <li><a href="inherits.html"><span>Class&#160;Hierarchy</span></a></li>
      <li><a href="functions.html"><span>Class&#160;Members</span></a></li>
    </ul>
  </div>
</div>
<div id="side-nav" class="ui-resizable side-nav-resizable">
  <div id="nav-tree">
    <div id="nav-tree-contents">
    </div>
  </div>
  <div id="splitbar" style="-moz-user-select:none;" 
       class="ui-resizable-handle">
  </div>
</div>
<script type="text/javascript">
  initNavTree('a00140.html','');
</script>
<div id="doc-content">
<div class="header">
  <div class="summary">
<a href="#pub-methods">Public Member Functions</a> &#124;
<a href="#pro-methods">Protected Member Functions</a> &#124;
<a href="#pro-attribs">Protected Attributes</a> &#124;
<a href="#pri-methods">Private Member Functions</a>  </div>
  <div class="headertitle">
<div class="title">MiximBatteryAccess Class Reference<div class="ingroups"><a class="el" href="a00530.html">Power consumption - Classes using/defining power consumption</a> &#124; <a class="el" href="a00516.html">baseModules - base module classes of MiXiM</a></div></div>  </div>
</div>
<div class="contents">
<!-- doxytag: class="MiximBatteryAccess" --><!-- doxytag: inherits="BaseModule" -->
<p>Extends <a class="el" href="a00027.html" title="Base class for all simple modules of a host.">BaseModule</a> by several methods which provide access to the battery module.  
 <a href="a00140.html#details">More...</a></p>

<p><code>#include &lt;<a class="el" href="a00278_source.html">MiximBatteryAccess.h</a>&gt;</code></p>
<div class="dynheader">
Inheritance diagram for MiximBatteryAccess:</div>
<div class="dyncontent">
<div class="center"><img src="a00861.png" border="0" usemap="#MiximBatteryAccess_inherit__map" alt="Inheritance graph"/></div>
<center><span class="legend">[<a target="top" href="graph_legend.html">legend</a>]</span></center></div>
<div class="dynheader">
Collaboration diagram for MiximBatteryAccess:</div>
<div class="dyncontent">
<div class="center"><img src="a00862.png" border="0" usemap="#MiximBatteryAccess_coll__map" alt="Collaboration graph"/></div>
<center><span class="legend">[<a target="top" href="graph_legend.html">legend</a>]</span></center></div>

<p><a href="a00863.html">List of all members.</a></p>
<table class="memberdecls">
<tr><td colspan="2"><h2><a name="pub-methods"></a>
Public Member Functions</h2></td></tr>
<tr><td class="memItemLeft" align="right" valign="top"><a class="anchor" id="a1e3f54678959626e25fbbb9a4eca38c5"></a><!-- doxytag: member="MiximBatteryAccess::MiximBatteryAccess" ref="a1e3f54678959626e25fbbb9a4eca38c5" args="(unsigned stacksize)" -->
&#160;</td><td class="memItemRight" valign="bottom"><b>MiximBatteryAccess</b> (unsigned stacksize)</td></tr>
<tr><td colspan="2"><h2><a name="pro-methods"></a>
Protected Member Functions</h2></td></tr>
<tr><td class="memItemLeft" align="right" valign="top">void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="a00140.html#a18d72d9f422e37b173dad102b1e6b8a8">registerWithBattery</a> (const std::string &amp;name, int numAccounts)</td></tr>
<tr><td class="mdescLeft">&#160;</td><td class="mdescRight">Registers this module as a device with the battery module.  <a href="#a18d72d9f422e37b173dad102b1e6b8a8"></a><br/></td></tr>
<tr><td class="memItemLeft" align="right" valign="top">void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="a00140.html#a3b26c010451c9d339aa342a4efa3b3d6">draw</a> (<a class="el" href="a00087.html">DrawAmount</a> &amp;amount, int account)</td></tr>
<tr><td class="mdescLeft">&#160;</td><td class="mdescRight">Draws the amount defined by the passed <a class="el" href="a00087.html" title="Defines the amount of power drawn by a device from a power source.">DrawAmount</a> from the battery on account of the passed account.  <a href="#a3b26c010451c9d339aa342a4efa3b3d6"></a><br/></td></tr>
<tr><td class="memItemLeft" align="right" valign="top">void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="a00140.html#a523efb31254a730e699983b50dbee44d">drawCurrent</a> (double amount, int account)</td></tr>
<tr><td class="mdescLeft">&#160;</td><td class="mdescRight">Draws the passed amount of current (in mA) over time from the battery on account of the passed account.  <a href="#a523efb31254a730e699983b50dbee44d"></a><br/></td></tr>
<tr><td class="memItemLeft" align="right" valign="top">void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="a00140.html#adad54ef2df7fd5bd9b2836a732cef743">drawEnergy</a> (double amount, int account)</td></tr>
<tr><td class="mdescLeft">&#160;</td><td class="mdescRight">Draws the passed amount of energy (in mWs) from the battery on account of the passed account.  <a href="#adad54ef2df7fd5bd9b2836a732cef743"></a><br/></td></tr>
<tr><td colspan="2"><h2><a name="pro-attribs"></a>
Protected Attributes</h2></td></tr>
<tr><td class="memItemLeft" align="right" valign="top"><a class="anchor" id="a76df8da8908d86b082817b03de36fcde"></a><!-- doxytag: member="MiximBatteryAccess::battery" ref="a76df8da8908d86b082817b03de36fcde" args="" -->
<a class="el" href="a00018.html">BaseBattery</a> *&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="a00140.html#a76df8da8908d86b082817b03de36fcde">battery</a></td></tr>
<tr><td class="mdescLeft">&#160;</td><td class="mdescRight">Stores pointer to the battery module. <br/></td></tr>
<tr><td class="memItemLeft" align="right" valign="top"><a class="anchor" id="ac8cd6166e3b0bd6e02b4113d360a41bb"></a><!-- doxytag: member="MiximBatteryAccess::deviceID" ref="ac8cd6166e3b0bd6e02b4113d360a41bb" args="" -->
int&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="a00140.html#ac8cd6166e3b0bd6e02b4113d360a41bb">deviceID</a></td></tr>
<tr><td class="mdescLeft">&#160;</td><td class="mdescRight">This devices id for the battery module. <br/></td></tr>
<tr><td colspan="2"><h2><a name="pri-methods"></a>
Private Member Functions</h2></td></tr>
<tr><td class="memItemLeft" align="right" valign="top"><a class="anchor" id="a9ba775d0bfe35ffa3640c3d68eea3364"></a><!-- doxytag: member="MiximBatteryAccess::MiximBatteryAccess" ref="a9ba775d0bfe35ffa3640c3d68eea3364" args="(const MiximBatteryAccess &amp;)" -->
&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="a00140.html#a9ba775d0bfe35ffa3640c3d68eea3364">MiximBatteryAccess</a> (const <a class="el" href="a00140.html">MiximBatteryAccess</a> &amp;)</td></tr>
<tr><td class="mdescLeft">&#160;</td><td class="mdescRight">Copy constructor is not allowed. <br/></td></tr>
<tr><td class="memItemLeft" align="right" valign="top"><a class="anchor" id="adb5cb04f46aa5bcf4b4b1f12d357e050"></a><!-- doxytag: member="MiximBatteryAccess::operator=" ref="adb5cb04f46aa5bcf4b4b1f12d357e050" args="(const MiximBatteryAccess &amp;)" -->
<a class="el" href="a00140.html">MiximBatteryAccess</a> &amp;&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="a00140.html#adb5cb04f46aa5bcf4b4b1f12d357e050">operator=</a> (const <a class="el" href="a00140.html">MiximBatteryAccess</a> &amp;)</td></tr>
<tr><td class="mdescLeft">&#160;</td><td class="mdescRight">Assignment operator is not allowed. <br/></td></tr>
</table>
<hr/><a name="details" id="details"></a><h2>Detailed Description</h2>
<div class="textblock"><p>Extends <a class="el" href="a00027.html" title="Base class for all simple modules of a host.">BaseModule</a> by several methods which provide access to the battery module. </p>
<dl class="author"><dt><b>Author:</b></dt><dd>Karl Wessel </dd></dl>
</div><hr/><h2>Member Function Documentation</h2>
<a class="anchor" id="a3b26c010451c9d339aa342a4efa3b3d6"></a><!-- doxytag: member="MiximBatteryAccess::draw" ref="a3b26c010451c9d339aa342a4efa3b3d6" args="(DrawAmount &amp;amount, int account)" -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">void MiximBatteryAccess::draw </td>
          <td>(</td>
          <td class="paramtype"><a class="el" href="a00087.html">DrawAmount</a> &amp;&#160;</td>
          <td class="paramname"><em>amount</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">int&#160;</td>
          <td class="paramname"><em>account</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td><code> [protected]</code></td>
        </tr>
      </table>
</div>
<div class="memdoc">

<p>Draws the amount defined by the passed <a class="el" href="a00087.html" title="Defines the amount of power drawn by a device from a power source.">DrawAmount</a> from the battery on account of the passed account. </p>
<p>If no battery module is available than nothing happens. </p>

<p>References <a class="el" href="a00140.html#a76df8da8908d86b082817b03de36fcde">battery</a>, <a class="el" href="a00140.html#ac8cd6166e3b0bd6e02b4113d360a41bb">deviceID</a>, and <a class="el" href="a00018.html#a4ac1773aef7363fc880a9689706ccc99">BaseBattery::draw()</a>.</p>
<div class="fragment"><pre class="fragment">{
  <span class="keywordflow">if</span>(!<a class="code" href="a00140.html#a76df8da8908d86b082817b03de36fcde" title="Stores pointer to the battery module.">battery</a>)
    <span class="keywordflow">return</span>;

  <a class="code" href="a00140.html#a76df8da8908d86b082817b03de36fcde" title="Stores pointer to the battery module.">battery</a>-&gt;<a class="code" href="a00018.html#a4ac1773aef7363fc880a9689706ccc99" title="Draws power from the battery.">draw</a>(<a class="code" href="a00140.html#ac8cd6166e3b0bd6e02b4113d360a41bb" title="This devices id for the battery module.">deviceID</a>, amount, account);
}
</pre></div>
</div>
</div>
<a class="anchor" id="a523efb31254a730e699983b50dbee44d"></a><!-- doxytag: member="MiximBatteryAccess::drawCurrent" ref="a523efb31254a730e699983b50dbee44d" args="(double amount, int account)" -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">void MiximBatteryAccess::drawCurrent </td>
          <td>(</td>
          <td class="paramtype">double&#160;</td>
          <td class="paramname"><em>amount</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">int&#160;</td>
          <td class="paramname"><em>account</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td><code> [protected]</code></td>
        </tr>
      </table>
</div>
<div class="memdoc">

<p>Draws the passed amount of current (in mA) over time from the battery on account of the passed account. </p>
<p>If no battery module is available than nothing happens. </p>

<p>Reimplemented in <a class="el" href="a00029.html#a81153199f268b4831f42b20b06959764">BasePhyLayer</a>, and <a class="el" href="a00174.html#aaaaec355a89dc49db47a3ca1e4ffaf90">PhyLayerBattery</a>.</p>

<p>References <a class="el" href="a00140.html#a76df8da8908d86b082817b03de36fcde">battery</a>, <a class="el" href="a00140.html#ac8cd6166e3b0bd6e02b4113d360a41bb">deviceID</a>, and <a class="el" href="a00018.html#a4ac1773aef7363fc880a9689706ccc99">BaseBattery::draw()</a>.</p>
<div class="fragment"><pre class="fragment">{
  <span class="keywordflow">if</span>(!<a class="code" href="a00140.html#a76df8da8908d86b082817b03de36fcde" title="Stores pointer to the battery module.">battery</a>)
    <span class="keywordflow">return</span>;

  <a class="code" href="a00087.html" title="Defines the amount of power drawn by a device from a power source.">DrawAmount</a> val(DrawAmount::CURRENT, amount);
  <a class="code" href="a00140.html#a76df8da8908d86b082817b03de36fcde" title="Stores pointer to the battery module.">battery</a>-&gt;<a class="code" href="a00018.html#a4ac1773aef7363fc880a9689706ccc99" title="Draws power from the battery.">draw</a>(<a class="code" href="a00140.html#ac8cd6166e3b0bd6e02b4113d360a41bb" title="This devices id for the battery module.">deviceID</a>, val, account);
}
</pre></div>
</div>
</div>
<a class="anchor" id="adad54ef2df7fd5bd9b2836a732cef743"></a><!-- doxytag: member="MiximBatteryAccess::drawEnergy" ref="adad54ef2df7fd5bd9b2836a732cef743" args="(double amount, int account)" -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">void MiximBatteryAccess::drawEnergy </td>
          <td>(</td>
          <td class="paramtype">double&#160;</td>
          <td class="paramname"><em>amount</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">int&#160;</td>
          <td class="paramname"><em>account</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td><code> [protected]</code></td>
        </tr>
      </table>
</div>
<div class="memdoc">

<p>Draws the passed amount of energy (in mWs) from the battery on account of the passed account. </p>
<p>If no battery module is available than nothing happens. </p>

<p>References <a class="el" href="a00140.html#a76df8da8908d86b082817b03de36fcde">battery</a>, <a class="el" href="a00140.html#ac8cd6166e3b0bd6e02b4113d360a41bb">deviceID</a>, <a class="el" href="a00018.html#a4ac1773aef7363fc880a9689706ccc99">BaseBattery::draw()</a>, and <a class="el" href="a00087.html#ae388439d3e21c30f465e2563199bbec4ad8fe7930899c36833e603cd89446d86f">DrawAmount::ENERGY</a>.</p>
<div class="fragment"><pre class="fragment">{
  <span class="keywordflow">if</span>(!<a class="code" href="a00140.html#a76df8da8908d86b082817b03de36fcde" title="Stores pointer to the battery module.">battery</a>)
    <span class="keywordflow">return</span>;

  <a class="code" href="a00087.html" title="Defines the amount of power drawn by a device from a power source.">DrawAmount</a> val(<a class="code" href="a00087.html#ae388439d3e21c30f465e2563199bbec4ad8fe7930899c36833e603cd89446d86f" title="Current in mA over time.">DrawAmount::ENERGY</a>, amount);
  <a class="code" href="a00140.html#a76df8da8908d86b082817b03de36fcde" title="Stores pointer to the battery module.">battery</a>-&gt;<a class="code" href="a00018.html#a4ac1773aef7363fc880a9689706ccc99" title="Draws power from the battery.">draw</a>(<a class="code" href="a00140.html#ac8cd6166e3b0bd6e02b4113d360a41bb" title="This devices id for the battery module.">deviceID</a>, val, account);
}
</pre></div>
</div>
</div>
<a class="anchor" id="a18d72d9f422e37b173dad102b1e6b8a8"></a><!-- doxytag: member="MiximBatteryAccess::registerWithBattery" ref="a18d72d9f422e37b173dad102b1e6b8a8" args="(const std::string &amp;name, int numAccounts)" -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">void MiximBatteryAccess::registerWithBattery </td>
          <td>(</td>
          <td class="paramtype">const std::string &amp;&#160;</td>
          <td class="paramname"><em>name</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">int&#160;</td>
          <td class="paramname"><em>numAccounts</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td><code> [protected]</code></td>
        </tr>
      </table>
</div>
<div class="memdoc">

<p>Registers this module as a device with the battery module. </p>
<p>If no battery module is available than nothing happens. </p>

<p>References <a class="el" href="a00140.html#a76df8da8908d86b082817b03de36fcde">battery</a>, <a class="el" href="a00140.html#ac8cd6166e3b0bd6e02b4113d360a41bb">deviceID</a>, <a class="el" href="a00027.html#aabf0226159b22b46e70031fd3bb3b1b2">BaseModule::findHost()</a>, and <a class="el" href="a00018.html#a6b2ac07e8d11823bdd239de2bfa4563a">BaseBattery::registerDevice()</a>.</p>

<p>Referenced by <a class="el" href="a00174.html#a815f95ad9fe89412ff3c5991ec1cfafe">PhyLayerBattery::initialize()</a>.</p>
<div class="fragment"><pre class="fragment">{
  <a class="code" href="a00140.html#a76df8da8908d86b082817b03de36fcde" title="Stores pointer to the battery module.">battery</a> = <a class="code" href="a00093.html" title="Provides method templates to find omnet modules.">FindModule&lt;BaseBattery*&gt;::findSubModule</a>(<a class="code" href="a00027.html#aabf0226159b22b46e70031fd3bb3b1b2" title="Function to get a pointer to the host module.">findHost</a>());

  <span class="keywordflow">if</span>(!<a class="code" href="a00140.html#a76df8da8908d86b082817b03de36fcde" title="Stores pointer to the battery module.">battery</a>) {
    opp_warning(<span class="stringliteral">&quot;No battery module defined!&quot;</span>);
  } <span class="keywordflow">else</span> {
    <a class="code" href="a00140.html#ac8cd6166e3b0bd6e02b4113d360a41bb" title="This devices id for the battery module.">deviceID</a> = <a class="code" href="a00140.html#a76df8da8908d86b082817b03de36fcde" title="Stores pointer to the battery module.">battery</a>-&gt;<a class="code" href="a00018.html#a6b2ac07e8d11823bdd239de2bfa4563a" title="Registers a power draining device with this battery.">registerDevice</a>(name, numAccounts);
  }
}
</pre></div>
</div>
</div>
<hr/>The documentation for this class was generated from the following files:<ul>
<li>D:/Projects/MiXiM/extsrc/mixim/src/base/modules/<a class="el" href="a00278_source.html">MiximBatteryAccess.h</a></li>
<li>D:/Projects/MiXiM/extsrc/mixim/src/base/modules/MiximBatteryAccess.cc</li>
</ul>
</div>
</div>
  <div id="nav-path" class="navpath">
    <ul>
      <li class="navelem"><a class="el" href="a00140.html">MiximBatteryAccess</a>      </li>

    <li class="footer">Generated on Tue Mar 5 2013 21:26:32 for MiXiM by
    <a href="http://www.doxygen.org/index.html">
    <img class="footer" src="doxygen.png" alt="doxygen"/></a> 1.7.5.1 </li>
   </ul>
 </div>


</body>
</html>
